Only comment out SET statements at the start of a line - #13
Merged
Conversation
ThoSap
approved these changes
Sep 7, 2026
Co-authored-by: Thomas Sapelza <thomas.sapelza@aboutbits.it>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
setup-postgres-preview-schemaaction rewrites the pg_dump output with sed before replaying it into the preview schema. The rule that comments out pg_dump's configuration statements was unanchored and global (s/SET /--SET /g), so it also rewrote every other occurrence ofSETin the dump:... ON DELETE SET NULL;→... ON DELETE --SET NULL;ALTER COLUMN "c" SET DEFAULT ...;→ALTER COLUMN "c" --SET DEFAULT ...;--starts a SQL comment, so the rest of the statement is swallowed and the restore fails with a syntax error (observed in wm-connect-api, whose schema has anON DELETE SET NULLforeign key: failing run).How
Anchor the pattern to the start of the line:
s/^SET /--SET /. pg_dump only emits itsSETconfiguration statements (statement_timeout,search_path, ...) at column 0, whileSET NULL/SET DEFAULTonly occur mid-statement on indented lines, so the anchor cleanly separates the two. Thegflag is dropped since only oneSETcan start a line.